<template>
   <div>
               <!-- 数据 -->
        <el-table :data="tableData"  style="width: 100%">
            <el-table-column type="index" label="序号" align="center"> </el-table-column>
            <el-table-column prop="month" label="是否月租" align="center">
                <template slot-scope="scope">
                    {{scope.row.month == 0? '是' :'否'}}
                </template>
                 </el-table-column>
                             <el-table-column prop="category" label="租赁类型" align="center"> 
                    <template slot-scope="scope">
                    {{scope.row.category == 0? '托盘' :scope.row.category == 2? '立方' :'平方'}}
                </template>
            </el-table-column>
                        <el-table-column prop="number" label="租赁数量" align="center"> </el-table-column>
                                    <el-table-column prop="price" label="租赁单价" align="center"> </el-table-column>
            <el-table-column prop="start" label="开始租赁时间" align="center"> </el-table-column>
            <el-table-column prop="end" label="结束租赁时间" align="center"> </el-table-column>
          <el-table-column prop="isPay" label="是否已经付款" align="center">
                <template slot-scope="scope">
                    {{scope.row.isPay == 1? '已付款' :'未付款'}}
                </template>
                 </el-table-column>
                 <el-table-column fixed="right" label="操作" align="center">
                <template slot-scope="scope">
                    <el-button type="text" size="small" icon="el-icon-edit" @click="onsumil(scope.row) ">确认缴费</el-button>
                </template>
            </el-table-column>
        </el-table>
        <div class="block">
            <el-pagination
            style="float:right;"
            background
            v-if="hide"
                @size-change="handleSizeCha"
                @current-change="handleCurrentCha"
                :current-page="formInline.pageNum"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="formInline.pageSize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="total"
            >
            </el-pagination>
        </div>
   </div>
</template>

<script>
import{Recorddetails,Paymentconfirmation} from '../../api/user.js'
export default {
    data(){
        return {
            // 数据
            tableData:[],
            // 分页
             formInline: {
                pageNum: 1,
                pageSize: 10
            },
             // 数据总条目数
            total:undefined,
            hide:false
        }
    },
    methods:{
        // 数据
         onSubmit() {
            Recorddetails(this.formInline).then((ref) => {
                // console.log(ref);
                this.tableData = ref.rows;
                this.total = ref.total
                if(ref.rows == ''){
                    this.hide=false
                }else{
                    this.hide= true
                }
            });
        },
                        // 页面分页
        handleSizeCha(val){
            this.formInline.pageSize = Number(val);
            this.onSubmit();
        },
        // 页面分页(几个)
                handleCurrentCha(val) {
            this.formInline.pageNum = Number(val);
            this.onSubmit();
        },
        // 确认缴费
        onsumil(val){
            val.isPay = 1
            this.$confirm('是否确认缴费?', '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            Paymentconfirmation(val).then((ref)=>{
                console.log(ref);
                this.onSubmit()
            })
          this.$message({
            type: 'success',
            message: '修改成功!'
          });
        })
        }
    },
    mounted(){
        this.onSubmit()
    }
}
</script>

<style scoped>
.block{
    height: 20px;
    margin-top: 10px;
}
</style>
